<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<form:form commandName="model" cssClass="validate"
	action="db/entityField/save">
	<form:hidden path="id" />
	<form:hidden path="dbEntityId" />
	<table class=" form-table">
		<tbody>
			<tr>
				<td class="td1">名称：</td>
				<td class="td2"><form:input path="name" cssClass="required" />
				</td>
			</tr>
			<tr>
				<td class="td1">字段类型：</td>
				<td class="td2"><form:radiobutton path="fieldType"
						value="string" label="字符串" cssClass="required" /> <form:radiobutton
						path="fieldType" value="number" label="数字" cssClass="required" />
					<form:radiobutton path="fieldType" value="date" label="日期"
						cssClass="required" /> <form:radiobutton path="fieldType"
						value="datetime" label="时间" cssClass="required" /></td>
			</tr>
			<tr>
				<td class="td1">数据库列名：</td>
				<td class="td2"><form:input path="columnName" cssClass="hidden" />
					<isperp:listSelector id="columnNameSelector" showPager="false"
						displayValue="${model.columnName }" valueControlId="columnName"
						url="db/entity/showColumns?id=${model.dbEntityId }"
						valueColumn="column_name" displayColumn="column_name">
						<isperp:column name="column_name" title="字段名称"></isperp:column>
						<isperp:column name="column_type" title="字段类型"></isperp:column>
					</isperp:listSelector>
				</td>


			</tr>
			<tr>
				<td class="td1">特性：</td>
				<td class="td2"><form:checkbox path="notnull" label="非空" /> <form:checkbox
						path="uniqueKey" label="唯一" /> <form:checkbox path="useForImport"
						label="用于导入" /> <form:checkbox path="slmCalculateField"
						label="用于slm计算" /> <form:checkbox path="dataChangeLog"
						label="执行数据变更日志" /> <form:checkbox path="domainField"
						label="项目域标识字段" /><form:checkbox path="useForChange"
						label="用于变更" /></td>
			</tr>
			<tr>
				<td class="td1">长度：</td>
				<td class="td2"><form:input path="minLength" cssClass="number"
						cssStyle="width:70px" />到 <form:input path="maxLength"
						cssClass="number" cssStyle="width:70px" /></td>
			</tr>
			<tr>
				<td class="td1">属性分类名称：</td>
				<td class="td2">
				  <isperp:dictSelector typeCode="CHANGE_CIFILEDCATEGORY"
				name="filedCategoryName" id="filedCategoryName" hasEmptyValue="true" codeValue="true" dataWidth="260px"
				dictCssClass="" selectedValue="${model.filedCategoryName }"></isperp:dictSelector>
				
				</td>
			</tr>
			<tr>
				<td class="td1">sql定义：</td>
				<td class="td2"><form:input path="sqlStr" cssStyle="width:80%" />
				</td>
			</tr>
			<tr>
				<td class="td1">验证表达式：</td>
				<td class="td2"><form:input path="validateExp"
						cssStyle="width:80%" /></td>
			</tr>
			<tr>
				<td class="td1">验证说明：</td>
				<td class="td2"><form:input path="validateDesc"
						cssStyle="width:80%" /></td>
			</tr>
			<tr>
				<td class="td1">排序：</td>
				<td class="td2"><form:input path="orderNum" cssClass="number" />
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<fieldset class="ui-widget ui-widget-content">
						<legend>
							&nbsp;&nbsp;<input id="cbFieldControl" name="cbFieldControl"
								type="checkbox"
								${haveControl}
							onchange="fsFieldControl_Onchange(this)"
								value="1"><label for="cbFieldControl">定义字段控件</label>&nbsp;
						</legend>
						<input name="controlId" type="hidden" value="${fieldControl.id}">
						<table class="form-table" id="tbFieldControl" style="display:none">
							<tr>
								<td class="td1">类型：</td>
								<td class="td2"><select name="controlControlType">
										<option value="select">下拉</option>
										<option value="tree">树形选择</option>
										<option value="date">日期选择</option>
										<option value="datetime">时间选择</option>
										<option value="content">自定义</option>
								</select></td>
							</tr>
							<tr>
								<td class="td1">数据源：</td>
								<td class="td2"><select name="controlDatasourceEntityId">
										<c:forEach var="entry" items="${datasourceList}">
											<c:choose>
												<c:when
													test="${fieldControl.datasourceEntityId eq entry.id}">
													<option value="${entry.id}" selected="selected">${entry.name}</option>
												</c:when>
												<c:otherwise>
													<option value="${entry.id}">${entry.name}</option>
												</c:otherwise>
											</c:choose>
										</c:forEach>
								</select>
								</td>
							</tr>
							<tr>
								<td class="td1">值字段：</td>
								<td class="td2"><input type="text" name="controlValueField"
									value="${fieldControl.valueField}" class="required" />
								</td>
							</tr>
							<tr>
								<td class="td1">显示字段：</td>
								<td class="td2"><input type="text"
									name="controlDisplayField" value="${fieldControl.displayField}"
									class="required" />
								</td>
							</tr>
							
							<tr>
								<td class="td1">自定义值：</td>
								<td class="td2">
									<textarea rows="3" name="contentValue" id="contentValue" cols="3" style="font-size:16px;">${fieldControl.contentValue}</textarea>
								</td>
							</tr>
							
							<tr>
								<td class="td1">过滤：</td>
								<td class="td2"><input name="controlFilter"
									value="${fieldControl.filter}" type="text" style="width:90%">
								</td>
							</tr>
						</table>
					</fieldset>
				</td>
			<tr>
		</tbody>
	</table>
	<isperp:buttonList>
		<button class="submit" onclick="isperp.submitForm();return false;">
			<span class="icon icon-save"></span>提交
		</button>
	</isperp:buttonList>
</form:form>
<script type="text/javascript">
	function fsFieldControl_Onchange(obj) {
		var result = $("#cbFieldControl:checked").val();
		if (result == "1") {
			$("#tbFieldControl").show();

		} else {
			$("#tbFieldControl").hide();
		}
	}

	$(document).ready(function() {

		fsFieldControl_Onchange();

	});
</script>
